package com.qfedu.zf.index.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.zf.common.vo.R;
import com.qfedu.zf.index.entity.City;
import com.qfedu.zf.index.mapper.CityMapper;
import com.qfedu.zf.index.service.CityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 存储城市信息 服务实现类
 * </p>
 *
 * @author wgz
 * @since 2024-06-18
 */
@Service
public class CityServiceImpl extends ServiceImpl<CityMapper, City> implements CityService {

    @Autowired
    private CityMapper cityMapper;

    @Override
    public R selectAll(Map<String, Object> map) {
        QueryWrapper<City> queryWrapper = new QueryWrapper<>();
        if (map.get("name") != null){
            queryWrapper.eq("name",map.get("name"));
        }
        queryWrapper.orderByAsc("initial");
        List<City> cities = cityMapper.selectList(queryWrapper);
        return R.ok(cities);
    }
}
